#include <cstdio>

void swap (int& a, int& b);

int main(){
    int num = 9;
    int num2 = 8;
    // 初始化引用
    int& rnum = num;
    int& rnum2 = num2;
    rnum++;
    printf("num address: %p\n",&num);
    printf("rnum address: %p\n",&rnum);
    printf("%d",rnum);
    swap(num,num2);
    printf("num: %d,num2: %d \n",rnum,rnum2);
}

// 通过引用的方式传递参数, 形参会修饰实参
void swap (int& a, int& b){
    int temp = a;
    a = b;
    b= temp;
}
